
<h1><span class="yiyi-st" id="yiyi-13">numpy.random.RandomState.rand</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.RandomState.rand.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.RandomState.rand.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="method">
<dt id="numpy.random.RandomState.rand"><span class="yiyi-st" id="yiyi-14"> <code class="descclassname">RandomState.</code><code class="descname">rand</code><span class="sig-paren">(</span><em>d0</em>, <em>d1</em>, <em>...</em>, <em>dn</em><span class="sig-paren">)</span></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-15">给定形状中的随机值。</span></p>
<p><span class="yiyi-st" id="yiyi-16">创建给定形状的数组并使用来自<code class="docutils literal"><span class="pre">[0， t&gt; <span class="pre">1）</span></span></code>的均匀分布的随机样本填充它。</span></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name">
<col class="field-body">
<tbody valign="top">
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-17">参数：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-18"><strong>d0，d1，...，dn</strong>：int，可选</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-19">返回的数组的尺寸应该都是正数。</span><span class="yiyi-st" id="yiyi-20">如果没有给出参数，则返回单个Python浮动。</span></p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name"><span class="yiyi-st" id="yiyi-21">返回：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-22"><strong>out</strong>：ndarray，shape <code class="docutils literal"><span class="pre">（d0，</span> <span class="pre">d1，</span> <span class="pre">...，</span> <span class="pre">dn） </span></code></span></p>
<blockquote class="last">
<div><p><span class="yiyi-st" id="yiyi-23">随机值。</span></p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title"><span class="yiyi-st" id="yiyi-24">也可以看看</span></p>
<p class="last"><span class="yiyi-st" id="yiyi-25"><a class="reference internal" href="numpy.random.random.html#numpy.random.random" title="numpy.random.random"><code class="xref py py-obj docutils literal"><span class="pre">random</span></code></a></span></p>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-26">笔记</span></p>
<p><span class="yiyi-st" id="yiyi-27">这是一个方便的功能。</span><span class="yiyi-st" id="yiyi-28">如果你想要一个采用形状元组作为第一个参数的接口，请参考np.random.random_sample。</span></p>
<p class="rubric"><span class="yiyi-st" id="yiyi-29">例子</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">rand</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span>
<span class="go">array([[ 0.14022471,  0.96360618],  #random</span>
<span class="go">       [ 0.37601032,  0.25528411],  #random</span>
<span class="go">       [ 0.49313049,  0.94909878]]) #random</span>
</pre></div>
</div>
</dd></dl>
